import request from "@/utils/request";

const BASE_URL_WAREHOUSE = "/api/warehouse/";

const WarehouseAPI = {
  getWarehouseOptions(query: string) {
    return request<any, OptionType[]>({
      url: `${BASE_URL_WAREHOUSE}options/`,
      method: "get",
      params: {
        search: query,
      },
    });
  },
  addInOutRecord(record: InOutRecord) {
    return request<any, any>({
      url: `${BASE_URL_WAREHOUSE}inout/`,
      method: "post",
      data: record,
    });
  },
  getInOutRecords(warehouseCode: string) {
    return request<any, InOutRecord[]>({
      url: `${BASE_URL_WAREHOUSE}records/`,
      method: "get",
      params: {
        warehouseCode,
      },
    });
  },
};

export { WarehouseAPI };

interface InOutRecord {
  id?: string;
  warehouseCode: string;
  operationType: string;
  productId?: string;
  date_range?: string;
  barcode: string;
  quantity?: number;
  timestamp?: string;
}

export { InOutRecord };
